﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace FancyIdea.PingShui.Core.Util
{
    public class Summary
    {
        public static string Md5Base64(string text)
        {
            return GetBase64Summary(MD5.Create(), text);
        }

        public static string Sha1Base64(string text)
        {
            return GetBase64Summary(SHA1.Create(), text);
        }

        private static Encoding DefaultEncoding
        {
            get
            {
                return Encoding.UTF8;
            }
        }

        private static string GetBase64Summary(HashAlgorithm algorithm,
            string text)
        {
            return Convert.ToBase64String(algorithm.ComputeHash(
                DefaultEncoding.GetBytes(text)));
        }
    }
}